package cn.gailvlun.gll.presentation.login

import android.os.CountDownTimer


object CountDownTimerWrapper {

    const val TOTAL_TIMES = 60_000L
    const val INTERVAL = 1_000L

    var countDown: Long = 60L
    var phoneNumberWithCc: String? = null
    var id: Int? = null

    private val timer: CountDownTimer = object : CountDownTimer(TOTAL_TIMES, INTERVAL) {
        override fun onFinish() {
            countDown = 60L
        }

        override fun onTick(p0: Long) {
            countDown = p0 / INTERVAL
        }
    }

    fun startOnlyOnce() {
        if (countDown == 60L) {
            timer.start()
        }
    }

    fun cancel() {
        timer.cancel()
    }

}